package com.woniu.market_stall.mapper;

import com.woniu.market_stall.entity.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleMapper {
    int deleteByPrimaryKey(Integer id);
    @Update("update role set is_delete = 1 where id = #{id}")
    int deleteBPK(Integer id);

    int insert(Role record);

    Role selectByPrimaryKey(Integer id);

    List<Role> selectAll();

    int updateByPrimaryKey(Role role);

    List<Role> selcetRoleByName(String name);
    @Delete("update manager_url_role set is_delete = 1 where role_id = #{id}")
    void deleteManagerRoleByRoleId(Integer id);
    @Delete("update role_url_permission set is_delete = 1 where role_id = #{id}")
    void deleteRolePermissionByRoleId(Integer id);

//    @Delete("delete from manager_url_role where role_id = #{id}")
//    void deleteManagerRoleByRoleId(Integer id);
//    @Delete("delete from role_url_permission where role_id = #{id}")
//    void deleteRolePermissionByRoleId(Integer id);

    void insertPermissionByRole(@Param("roleId") int id, @Param("perArr") int[] perCheckedIds);


}